package client;

import client.netty.NetWorkClient;
import entity.BaseTank;
import lombok.Data;
import server.netty.GpcDataPackage;
import view.TankClientView;

@Data
public class TankClient {

	private String clientId;
	private BaseTank tank;
	private NetWorkClient client;
	private GpcResponseListener listener = null;
	
	
	public void start() {
		System.out.println("正在启动客户端...");
		TankClientView.getWINDOW().setVisible(true);
		System.out.println("客户端正在连接服务器...");
		listener = GpcResponseListener.getInstance(this);
		System.out.println("连接成功...");
	}
	
	public void messageResponse(GpcDataPackage message) {
		if(message.getStatus() == 1) {
			this.clientId = message.getUnique();
			if (this.listener != null) {
				this.listener.response(message);
			}
		} else {
			if (this.listener != null) {
				message.setUnique(clientId);
				this.listener.response(message);
			}
		}
	}
	
	
	
	
	
}
